document.querySelectorAll('.nav-links a').forEach(link => {
    link.addEventListener('click', function(e) {
        e.preventDefault(); // 阻止默认跳转
        const mainContent = document.querySelector('.main-content'); //获取主内容区
        mainContent.style.transition = 'opacity 0.5s'; // 设置淡入淡出的过渡时间
        mainContent.style.opacity = '0'; // 淡出
        setTimeout(() => {
            window.location.href = link.href; // 0.5秒后再跳转到目标链接
        }, 500);
    });
});

  document.addEventListener('DOMContentLoaded', function() {
      const mainContent = document.querySelector('.main-content');
      mainContent.style.transition = 'opacity 0.6s';
      mainContent.style.opacity = '0';
      setTimeout(() => {
          mainContent.style.opacity = '1';
      }, 100); // 0.1s  后页面淡入
  });